//
//  JYAddressCell.m
//  JYFarm
//
//  Created by 花花 on 2017/10/12.
//  Copyright © 2017年 花花. All rights reserved.
//

#import "JYAddressCell.h"

@implementation JYAddressCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{



    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupSubView];
    }
    return self;

}

- (void)setupSubView{

    [self addSubview:self.titleLabel];
    [self addSubview: self.subLabel];

}

- (void)layoutSubviews{

    [super layoutSubviews];
    
    JYWeakSelf;
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf);
        make.left.mas_equalTo(10);
    }];

    [self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf);
        make.left.mas_equalTo(weakSelf.titleLabel.mas_right);
    }];

}

- (UILabel *)titleLabel{

    if (!_titleLabel) {
        _titleLabel = [UILabel labelText:@"" fontSize:13 textColor:k3Color textAlignment:NSTextAlignmentLeft];
    }
    return _titleLabel;

}

- (UILabel *)subLabel{

    if (!_subLabel) {
        _subLabel = [UILabel labelText:@"" fontSize:13 textColor:k3Color textAlignment:NSTextAlignmentCenter];
    }
    return _subLabel;

}

- (void)setModel:(JYAddressModel *)model{

    _model = model;
/*
 JYAddressType_MerchantName, //商家名称
 JYAddressType_ReceivingName,//收货人
 JYAddressType_Contactnumber,//收货人电话
 JYAddressType_Address, //收货地址
 JYAddressType_DistributionTime,//配送时间
 */
    switch (model.type) {
        case JYAddressType_MerchantName:
        self.subLabel.text = model.merchantName;

            break;
        case JYAddressType_ReceivingName:
            self.subLabel.text = model.receivingName;
            
            break;
        case JYAddressType_Contactnumber:
            self.subLabel.text = model.contactnumber;
            
            break;
        case JYAddressType_Address:
            self.subLabel.text = model.address;
            
            break;
        case JYAddressType_DistributionTime:
            self.subLabel.text = model.distributionTime;
            
            break;
            
        default:
            break;
    }


}

@end
